#include "TextEdit.h"

#include <QFocusEvent>


TextEdit::TextEdit( QWidget * parent ) :
    QTextEdit( parent ),
    hasChanged( false )
{
    connect( this, SIGNAL( textChanged() ), this, SLOT( textHasChanged() ) );
}

void TextEdit::focusOutEvent( QFocusEvent * e )
{
    if( e->lostFocus() && hasChanged )
    {
        hasChanged = false;
        emit editingFinished();
    }
}

void TextEdit::textHasChanged()
{
    hasChanged = true;
}